package com.zrwl.poscloud.core.restapi.admin.baseInfo;
import com.zrwl.poscloud.base.entity.Admin;
import com.zrwl.poscloud.commons.utils.StringUtils;
import com.zrwl.poscloud.core.annotion.AuthorityVerify.AuthorityVerify;
import com.zrwl.poscloud.core.annotion.OperationLogger.OperationLogger;
import com.zrwl.poscloud.commons.exception.ThrowableUtils;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.validator.group.Delete;
import com.zrwl.poscloud.commons.validator.group.GetList;
import com.zrwl.poscloud.commons.validator.group.Insert;
import com.zrwl.poscloud.commons.validator.group.Update;
import com.zrwl.poscloud.xo.service.AdminService;
import com.zrwl.poscloud.xo.service.TeacherAdminRService;
import com.zrwl.poscloud.xo.vo.AdminVO;
import com.zrwl.poscloud.xo.vo.TeacherAdminRVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zrwl.poscloud.xo.service.TimeTableDetailService;
import com.zrwl.poscloud.xo.vo.TimeTableDetailVO;
/**
 * 管理员教师关联 controller api类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-05-08
 */
@RestController
@Api(value = "课程表明细相关接口", tags = {"课程表明细相关接口"})
@RequestMapping("/timeTableDetail")
@Slf4j
public class TimeTableDetailRestApi {
    @Autowired
    private TimeTableDetailService timeTableDetailService;
    @Autowired
    private TeacherAdminRService teacherAdminRService;
    @AuthorityVerify
    @ApiOperation(value = "获取课程表明细列表", notes = "获取课程表明细列表", response = String.class)
    @PostMapping("/getList")
    public String getList(@Validated({GetList.class}) @RequestBody TimeTableDetailVO timeTableDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取课程表明细列表: {}", timeTableDetailVO);
        return ResultUtil.successWithData(timeTableDetailService.getPageList(timeTableDetailVO));
    }

    @AuthorityVerify
    @ApiOperation(value = "获取课程表明细列表", notes = "获取课程表明细列表", response = String.class)
    @PostMapping("/getAllList")
    public String getAllList(@Validated({GetList.class}) @RequestBody TimeTableDetailVO timeTableDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取课程表明细列表: {}", timeTableDetailVO);
        return ResultUtil.successWithData(timeTableDetailService.getAllList(timeTableDetailVO));
    }

    @AuthorityVerify
    @OperationLogger(value = "新增课程表明细")    @ApiOperation(value = "新增课程表明细", notes = "新增课程表明细", response = String.class)
    @PostMapping("/add")
    public String add(@Validated({Insert.class}) @RequestBody TimeTableDetailVO timeTableDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("新增课程表明细: {}", timeTableDetailVO);
        return timeTableDetailService.add(timeTableDetailVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "修改课程表明细")    @ApiOperation(value = "修改课程表明细", notes = "修改课程表明细", response = String.class)
    @PostMapping("/edit")
    public String edit(@Validated({Update.class}) @RequestBody TimeTableDetailVO timeTableDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("修改课程表明细: {}", timeTableDetailVO);
        return timeTableDetailService.edit(timeTableDetailVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "删除课程表明细")    @ApiOperation(value = "删除课程表明细", notes = "删除课程表明细", response = String.class)
    @PostMapping("/delete")
    public String delete(@Validated({Delete.class}) @RequestBody TimeTableDetailVO timeTableDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("删除课程表明细: {}", timeTableDetailVO);
        return timeTableDetailService.delete(timeTableDetailVO);
    }
    @AuthorityVerify
    @ApiOperation(value = "获取教师课程表明细列表", notes = "获取教师课程表明细列表", response = String.class)
    @PostMapping("/getTeacherTimeTableList")
    public String getTeacherTimeTableList(@Validated({GetList.class}) @RequestBody TimeTableDetailVO timeTableDetailVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取教师课程表明细列表: {}", timeTableDetailVO);
        return ResultUtil.successWithData(timeTableDetailService.getTeacherTimeTableList(timeTableDetailVO));
    }
}
